﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Retirement/retirement.master" AutoEventWireup="true"
    CodeFile="myPolicy.aspx.cs" Inherits="Retirement_myPolicy" %>

<asp:Content ID="Content" ContentPlaceHolderID="retirement_ContentPlaceHolder" runat="Server">

    <h2 id="heading">
        <a href="../home.aspx">World Trade Bank</a> > <a href="home.aspx">Retirement</a>
        > My Policy</h2>

        <style type="text/css">     
        .tbl_policyStatement th, td
        {
            border: 1px solid #808080;
            text-align: left;
            height:30px;
        } 
        .tbl_policyStatement th
        {
            background-color: #B40404;
            color: #FFFFFF;
        }  
        .tbl_claimStatement th, td
        {
            border: 1px solid #808080;
            text-align: left;
            height:30px;
        }
        .tbl_claimStatement th
        {
            background-color: #B40404;
            color: #FFFFFF;
        }
        .tbl_changeStatement th, td
        {
            border: 1px solid #808080;
            text-align: left;
            height:30px;
        }
        .tbl_changeStatement th
        {
            background-color: #B40404;
            color: #FFFFFF;
        }
        
         .Grid th  
        {
            background-color: #B40404;
            color: #FFFFFF;
            height:30px;
        }
        
    </style>

    
<%
    
    if (this.policies == null || this.policies.Count == 0)
    {
       %>
       <asp:Label ID="lb_noPolicy" runat="server" Text="You don't have our retirement plan yet. Kindly make appointment with our representatives to apply for the plan with the link below:"></asp:Label><br /><br />
       <asp:HyperLink ID="HyperLink_appointment" runat="server" NavigateUrl="~/retirement/onlineAppointment.aspx">Make An Appointment</asp:HyperLink>
       <% 
    }
    else
    {
      
    %>
    
    <asp:GridView ID="gv_alertList" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="alert_id"  BackColor="White" 
            BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
            ForeColor="Black" GridLines="Vertical" 
        onselectedindexchanged="gv_alertList_SelectedIndexChanged" Width="70%" 
            >
            <AlternatingRowStyle BackColor="White" />
            <Columns>
            <asp:TemplateField HeaderText="No." >
                  <ItemTemplate>
                    <%# Container.DataItemIndex + 1 %>
                     <asp:HiddenField ID="hd_alertId" Value='<%# Bind("alert_id") %>' runat="server" />
                 </ItemTemplate>
                  <ItemStyle Width="5%" />
             </asp:TemplateField>

                <asp:BoundField DataField="category" HeaderText="Alert Category" 
                    SortExpression="category" >
                <ItemStyle Width="35%" />
                </asp:BoundField>
                <asp:BoundField DataField="info" HeaderText="Information" SortExpression="info">
                <ItemStyle Width="50%" />
                </asp:BoundField>
                <asp:BoundField DataField="cust_id" HeaderText="custId" SortExpression="custId" 
                    Visible="False" />
               <%-- <asp:HyperLinkField DataNavigateUrlFields="URL" DataTextField="URL" 
                    HeaderText="Check Detail" /> --%>
                <asp:CommandField ButtonType="Button" SelectText="Delete" 
                    ShowSelectButton="True" >
                <ItemStyle Width="10%" />
                </asp:CommandField>
            </Columns>
            <FooterStyle BackColor="#CCCC99" />
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
            <RowStyle BackColor="#F7F7DE" />
            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#FBFBF2" />
            <SortedAscendingHeaderStyle BackColor="#848384" />
            <SortedDescendingCellStyle BackColor="#EAEAD3" />
            <SortedDescendingHeaderStyle BackColor="#575357" />
        </asp:GridView>
    <p style="font-family: 'Oxygen', Arial; font-weight: bold; font-size: 40px">
        Policy Statement</p>
        <p>
        <asp:GridView ID="gv_policyStatement" runat="server" AutoGenerateColumns="False" 
                Width="100%" CssClass="Grid" onrowdatabound="gv_policyStatement_RowDataBound" DataKeyNames="policyNo">
        <Columns>
        <asp:BoundField ItemStyle-Width="150px" DataField="policyNo" 
                HeaderText="Plan Name" >
        <ItemStyle Width="150px"></ItemStyle>
        </asp:BoundField>
        <asp:BoundField ItemStyle-Width="150px" DataField="policyNo" HeaderText="Policy No." >
        <ItemStyle Width="150px"></ItemStyle>
        </asp:BoundField>
        <asp:BoundField ItemStyle-Width="150px" DataField="basicSumInsured" 
                HeaderText="Basic Sum Insured" >
        <ItemStyle Width="150px"></ItemStyle>
        </asp:BoundField>
        <asp:BoundField ItemStyle-Width="150px" DataField="plusRiderSumInsured" 
                HeaderText="Rider Sum Insured" >
        <ItemStyle Width="150px"></ItemStyle>
        </asp:BoundField>
        <asp:BoundField ItemStyle-Width="150px" DataField="waiverRiderPremium" 
                HeaderText="Waiver Rider Premium" >
        <ItemStyle Width="150px"></ItemStyle>
        </asp:BoundField>
         <asp:BoundField ItemStyle-Width="150px" DataField="totalAnnualPremium" 
                HeaderText="Total Premium Paid" >
        <ItemStyle Width="150px"></ItemStyle>
        </asp:BoundField>
            <asp:BoundField DataField="status"  
                HeaderText="Status">
            <ItemStyle Width="100px" />
            </asp:BoundField>
        </Columns>
            </asp:GridView>   
        </p>

       <br />
    <p style="font-family: 'Oxygen', Arial; font-weight: bold; font-size: 40px">
        Recent Activites</p>

        <p>
        
            <asp:GridView ID="gv_recentActivities" runat="server" Width="100%" AutoGenerateColumns="False"
                CssClass="Grid" AllowPaging="True" AllowSorting="True" 
                DataSourceID="SqlDataSource_recentActivities">
                <Columns>
                    <asp:BoundField DataField="plan_name" HeaderText="Plan Name" />
                    <asp:BoundField DataField="policy_no" HeaderText="Policy No." />
                    <asp:BoundField DataField="request_type_translate" HeaderText="Activity Description" />
                    <asp:BoundField DataField="request_time" NullDisplayText="-" 
                        HeaderText="Request Date" DataFormatString="{0:d}" />
                    <asp:BoundField DataField="status" HeaderText="Status" />
                    <asp:BoundField DataField="response_time" NullDisplayText="-" 
                        HeaderText="Response Date" DataFormatString="{0:d}" />
                </Columns>
            </asp:GridView>
        
        </p>
       <br />
        <p style="font-family: 'Oxygen', Arial; font-weight: bold; font-size: 40px">
        Payment History</p>
       <p>
       
       
           <asp:GridView ID="gv_paymentHistory" runat="server" Width="100%" AutoGenerateColumns="False"
                CssClass="Grid" AllowPaging="True" AllowSorting="True" 
               DataSourceID="SqlDataSource_paymentHistory">
               <Columns>
                   <asp:BoundField DataField="plan_name" HeaderText="Plan Name"/>
                   <asp:BoundField DataField="policy_no" HeaderText="Policy No."/>
                   <asp:BoundField DataField="type" HeaderText="Payment Type"/>
                   <asp:BoundField DataField="amount" HeaderText="Amount" 
                       DataFormatString="{0:c}"/>
                   <asp:BoundField DataField="payment_datetime" HeaderText="Payment Date" 
                       DataFormatString="{0:d}"/>
               </Columns>

           </asp:GridView>
       
       
       </p>
   <%-- <p style="font-family: 'Oxygen', Arial; font-weight: bold; font-size: 40px">
        Claim Statement</p>

       <table class="tbl_claimStatement" width="100%" style="border-collapse: collapse">
       <tr>
       <th>Plan Type</th>
       <th>Policy No.</th>
       <th>Claim Description</th>
       <th>Amount Claimed (S$)</th>
       <th>Claim Status</th>
       <th>Handled Date</th>
       </tr>
       <tr>
       <td>Flexi Protect</td>
       <td>FP1234567</td>
       <td>Critical Iillness</td>
       <td>100,000</td>
       <td>Pending</td>
       <td>-</td>
       </tr>
       </table>--%>
       <asp:SqlDataSource ID="SqlDataSource_recentActivities" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT        'Flexi Protect' AS plan_name, - C.claim_id AS request_id, C.policy_no, 'APPROVED' AS status, 
                         CASE claim_type WHEN 'ANGIOPLASTY' THEN 'ANGIOPLASTY CLAIM' WHEN 'CRITICAL_ILLNESS' THEN 'CRITICAL ILLNESS CLAIM' WHEN 'DISABILITY' THEN 'TOTAL/PERMANENT DISABILITY CLAIM'
                          WHEN 'TERMINAL_ILLNESS' THEN 'TERMINAL ILLNESS CLAIM' WHEN 'DEATH' THEN 'DEATH CLAIM' END AS request_type_translate, NULL AS request_time, 
                         C.claim_date AS response_time, '' AS reason
FROM            R_CLAIM AS C INNER JOIN
                         R_POLICY AS P ON C.policy_no = P.policy_no
WHERE        (P.user_id = @userId)
UNION ALL
SELECT        'Flexi Protect' AS plan_name, R.request_id, P.policy_no, R.status, 
                         CASE [request_type] WHEN 'SWITCH_REDIRECT' THEN 'FUND SWITHCH / PREMIUM REDIRECT' WHEN 'PREMIUM_TOP_UP' THEN 'SINGLE PREMIUM TOP-UP' WHEN
                          'WITHDRAWAL_TERMINATE' THEN 'WITHDRAWAL / TERMINATE' WHEN 'WITHDRAWAL' THEN 'WITHDRAWAL / TERMINATE' WHEN 'TERMINATE' THEN 'WITHDRAWAL / TERMINATE'
                          WHEN 'CHANGE_DETAILS' THEN 'CHANGE DETAILS' ELSE request_type END AS request_type_translate, R.request_time, CASE [response_time] WHEN NULL 
                         THEN NULL ELSE response_time END AS response_time, R.reason
FROM            R_REQUEST AS R INNER JOIN
                         R_POLICY AS P ON R.policy_no = P.policy_no
WHERE        (P.user_id = @userId)">
           <SelectParameters>
               <asp:SessionParameter DefaultValue="15369472" Name="userId" 
                   SessionField="userID" />
           </SelectParameters>
    </asp:SqlDataSource>
       <asp:SqlDataSource ID="SqlDataSource_paymentHistory" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT 'Flexi Protect' as plan_name, P.policy_no, [payment_datetime], 
        case when Y.type='PREMIUM' THEN 0-(COALESCE ( amount, 0 )+COALESCE(waiver_rider_amount,0))  else  COALESCE ( amount, 0 )+COALESCE(waiver_rider_amount,0)  END  as amount, [total_charges_amount], [invest_amount], [waiver_rider_amount], [manage_amount], [transaction_id], Y.type FROM R_PAYMENT Y, R_POLICY P
WHERE P.POLICY_NO=Y.POLICY_NO AND P.USER_ID=@userId">
           <SelectParameters>
               <asp:SessionParameter DefaultValue="15369472" Name="userId" 
                   SessionField="userID" />
           </SelectParameters>
    </asp:SqlDataSource>
       <br /><br />
        <p style="font-family: 'Oxygen', Arial; font-weight: bold; font-size: 40px">
       Withdrawal / Terminate</p>
    <br />
    Please complete the <a href="withdrawalTerminate.aspx" style="color:#B40404"; target="_blank">FlexiProtect Withdrawal / Terminate</a> application.<br /><br />

    <%
    }
     %>
</asp:Content>
